When the pointer is grabbed on an input window, either explicitely, or
authorOwen Taylor <otaylor@gtk.org>
Sat, 5 Sep 1998 21:22:51 +0000 (21:22 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 5 Sep 1998 21:22:51 +0000 (21:22 +0000)
Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>

* gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
When the pointer is grabbed on an input window,
either explicitely, or through press-grab, and
then grabbed on a non-input window, ungrab the
devices.

13 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdk.c
gdk/gdkinputgxi.h
gdk/gdkinputxfree.h
gdk/x11/gdkinput-gxi.c
gdk/x11/gdkinput-xfree.c
gdk/x11/gdkmain-x11.c

index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 6e0ce073854be9359406eda36f60f4b230683b98..4bf393e404122bbf7bd443f720b04d98b4a4b3b5 100644 (file)
@@ -1,3 +1,11 @@
+Sat Sep  5 16:01:19 1998  Owen Taylor  <otaylor@gtk.org>
+
+       * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h:
+       When the pointer is grabbed on an input window,
+       either explicitely, or through press-grab, and
+       then grabbed on a non-input window, ungrab the
+       devices.
+
 Sat Sep  5 07:13:19 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtktypeutils.h: don't include any gdk headers.
index 1932d7d3bc51ffbc8aeeb36ba534e339f63dbb69..5494657e7dc9aea65a7376beb458c22fa79c6a5d 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -1307,8 +1307,7 @@ gdk_pointer_grab (GdkWindow *       window,
        xevent_mask |= event_mask_table[i];
     }
   
-  if (((GdkWindowPrivate *)window)->extension_events &&
-      gdk_input_vtable.grab_pointer)
+  if (gdk_input_vtable.grab_pointer)
     return_val = gdk_input_vtable.grab_pointer (window,
                                                owner_events,
                                                event_mask,
index 74b3c0639ab3915bafc248c3d0b15726649b89b0..b4f331283842dd19a17c72f77438059d1431bd78 100644 (file)
@@ -593,16 +593,31 @@ gdk_input_gxi_grab_pointer (GdkWindow *     window,
 {
   GdkInputWindow *input_window, *new_window;
   GList *tmp_list;
+  GdkDevicePrivate *gdkdev;
+  GList *tmp_list;
 
   tmp_list = gdk_input_windows;
   while (tmp_list)
     {
       input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       return AlreadyGrabbed;
 
       if (input_window->window == window)
        new_window = input_window;
+      else (input_window->grabbed)
+       input_window->grabbed = FALSE;
+
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
+       {
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER && 
+             gdkdev->xdevice &&
+             (gdkdev->button_state != 0))
+           gdkdev->button_state = 0;
+         
+         tmp_list = tmp_list->next;
+       }
+      
       
       tmp_list = tmp_list->next;
     }
index c0411a4feaf646a226d4bd41c8a79aa1d33cd8ef..997fdd207b584122b1c4205a5e3d2fc718fba1e2 100644 (file)
@@ -257,6 +257,7 @@ gdk_input_xfree_grab_pointer (GdkWindow *     window,
                              guint32         time)
 {
   GdkInputWindow *input_window, *new_window;
+  gboolean need_ungrab;
   GdkDevicePrivate *gdkdev;
   GList *tmp_list;
   XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
@@ -265,47 +266,70 @@ gdk_input_xfree_grab_pointer (GdkWindow *     window,
 
   tmp_list = gdk_input_windows;
   new_window = NULL;
+  need_ungrab = FALSE;
+
   while (tmp_list)
     {
       input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       return AlreadyGrabbed;
 
       if (input_window->window == window)
        new_window = input_window;
-      
+      else if (input_window->grabbed)
+       {
+         input_window->grabbed = FALSE;
+         need_ungrab = TRUE;
+       }
+
       tmp_list = tmp_list->next;
     }
-  
-  g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
-  
-  new_window->grabbed = TRUE;
 
-  tmp_list = gdk_input_devices;
-  while (tmp_list)
+  if (new_window)
     {
-      gdkdev = (GdkDevicePrivate *)tmp_list->data;
-      if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
-         gdkdev->xdevice)
+      new_window->grabbed = TRUE;
+      
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
+       {
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
+             gdkdev->xdevice)
+           {
+             gdk_input_common_find_events (window, gdkdev,
+                                           event_mask,
+                                           event_classes, &num_classes);
+             
+             result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
+                                   GDK_WINDOW_XWINDOW (window),
+                                   owner_events, num_classes, event_classes,
+                                   GrabModeAsync, GrabModeAsync, time);
+             
+             /* FIXME: if failure occurs on something other than the first
+                device, things will be badly inconsistent */
+             if (result != Success)
+               return result;
+           }
+         tmp_list = tmp_list->next;
+       }
+    }
+  else
+    { 
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
        {
-         gdk_input_common_find_events (window, gdkdev,
-                                       event_mask,
-                                       event_classes, &num_classes);
-
-         result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
-                               GDK_WINDOW_XWINDOW (window),
-                               owner_events, num_classes, event_classes,
-                               GrabModeAsync, GrabModeAsync, time);
-
-         /* FIXME: if failure occurs on something other than the first
-            device, things will be badly inconsistent */
-         if (result != Success)
-           return result;
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
+             ((gdkdev->button_state != 0) || need_ungrab))
+           {
+             XUngrabDevice( gdk_display, gdkdev->xdevice, time);
+             gdkdev->button_state = 0;
+           }
+         
+         tmp_list = tmp_list->next;
        }
-      tmp_list = tmp_list->next;
     }
-  
+
   return Success;
+      
 }
 
 static void 
index 74b3c0639ab3915bafc248c3d0b15726649b89b0..b4f331283842dd19a17c72f77438059d1431bd78 100644 (file)
@@ -593,16 +593,31 @@ gdk_input_gxi_grab_pointer (GdkWindow *     window,
 {
   GdkInputWindow *input_window, *new_window;
   GList *tmp_list;
+  GdkDevicePrivate *gdkdev;
+  GList *tmp_list;
 
   tmp_list = gdk_input_windows;
   while (tmp_list)
     {
       input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       return AlreadyGrabbed;
 
       if (input_window->window == window)
        new_window = input_window;
+      else (input_window->grabbed)
+       input_window->grabbed = FALSE;
+
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
+       {
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER && 
+             gdkdev->xdevice &&
+             (gdkdev->button_state != 0))
+           gdkdev->button_state = 0;
+         
+         tmp_list = tmp_list->next;
+       }
+      
       
       tmp_list = tmp_list->next;
     }
index c0411a4feaf646a226d4bd41c8a79aa1d33cd8ef..997fdd207b584122b1c4205a5e3d2fc718fba1e2 100644 (file)
@@ -257,6 +257,7 @@ gdk_input_xfree_grab_pointer (GdkWindow *     window,
                              guint32         time)
 {
   GdkInputWindow *input_window, *new_window;
+  gboolean need_ungrab;
   GdkDevicePrivate *gdkdev;
   GList *tmp_list;
   XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
@@ -265,47 +266,70 @@ gdk_input_xfree_grab_pointer (GdkWindow *     window,
 
   tmp_list = gdk_input_windows;
   new_window = NULL;
+  need_ungrab = FALSE;
+
   while (tmp_list)
     {
       input_window = (GdkInputWindow *)tmp_list->data;
-      if (input_window->grabbed)
-       return AlreadyGrabbed;
 
       if (input_window->window == window)
        new_window = input_window;
-      
+      else if (input_window->grabbed)
+       {
+         input_window->grabbed = FALSE;
+         need_ungrab = TRUE;
+       }
+
       tmp_list = tmp_list->next;
     }
-  
-  g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
-  
-  new_window->grabbed = TRUE;
 
-  tmp_list = gdk_input_devices;
-  while (tmp_list)
+  if (new_window)
     {
-      gdkdev = (GdkDevicePrivate *)tmp_list->data;
-      if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
-         gdkdev->xdevice)
+      new_window->grabbed = TRUE;
+      
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
+       {
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
+             gdkdev->xdevice)
+           {
+             gdk_input_common_find_events (window, gdkdev,
+                                           event_mask,
+                                           event_classes, &num_classes);
+             
+             result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
+                                   GDK_WINDOW_XWINDOW (window),
+                                   owner_events, num_classes, event_classes,
+                                   GrabModeAsync, GrabModeAsync, time);
+             
+             /* FIXME: if failure occurs on something other than the first
+                device, things will be badly inconsistent */
+             if (result != Success)
+               return result;
+           }
+         tmp_list = tmp_list->next;
+       }
+    }
+  else
+    { 
+      tmp_list = gdk_input_devices;
+      while (tmp_list)
        {
-         gdk_input_common_find_events (window, gdkdev,
-                                       event_mask,
-                                       event_classes, &num_classes);
-
-         result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
-                               GDK_WINDOW_XWINDOW (window),
-                               owner_events, num_classes, event_classes,
-                               GrabModeAsync, GrabModeAsync, time);
-
-         /* FIXME: if failure occurs on something other than the first
-            device, things will be badly inconsistent */
-         if (result != Success)
-           return result;
+         gdkdev = (GdkDevicePrivate *)tmp_list->data;
+         if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
+             ((gdkdev->button_state != 0) || need_ungrab))
+           {
+             XUngrabDevice( gdk_display, gdkdev->xdevice, time);
+             gdkdev->button_state = 0;
+           }
+         
+         tmp_list = tmp_list->next;
        }
-      tmp_list = tmp_list->next;
     }
-  
+
   return Success;
+      
 }
 
 static void 
index 1932d7d3bc51ffbc8aeeb36ba534e339f63dbb69..5494657e7dc9aea65a7376beb458c22fa79c6a5d 100644 (file)
@@ -1307,8 +1307,7 @@ gdk_pointer_grab (GdkWindow *       window,
        xevent_mask |= event_mask_table[i];
     }
   
-  if (((GdkWindowPrivate *)window)->extension_events &&
-      gdk_input_vtable.grab_pointer)
+  if (gdk_input_vtable.grab_pointer)
     return_val = gdk_input_vtable.grab_pointer (window,
                                                owner_events,
                                                event_mask,